package assignment

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url("/api/v2/assignments/quizzesByIds") {
            queryParameters {
                parameter('type', "SUBJECTIVE_QUIZ")
                parameter('ids', "1,2")
            }
        }
        headers {
            contentType(applicationJsonUtf8())
            header('id', 21)
        }
    }
    response {
        status 200
        body("""
            [{
                "id": 1,
                "description":"subjectiveQuiz"
             },
             {
                "id": 2,
                "description":"subjectiveQuiz2"
             }]
        """)
        bodyMatchers {
            jsonPath('$.[*]', byType())
            jsonPath('$.[*].id', byRegex(number()))
            jsonPath('$.[*].description', byRegex(nonEmpty()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}